package org.baoping.demo.service.admin.impl;
import cn.hutool.core.collection.CollUtil;
import com.github.pagehelper.PageHelper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.baoping.demo.domain.entity.admin.SysAdmin;
import org.baoping.demo.mapper.admin.SysAdminMapper;
import org.baoping.demo.service.admin.SysAdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;
import java.util.List;
/**
 * @author HeZeMin
 * @className SysAdminServiceImpl
 * @description
 * @date 2021/1/11 17:27
 */
@Slf4j
@Service
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class SysAdminServiceImpl implements SysAdminService {
    private final SysAdminMapper adminMapper;

    @Override
    public List<SysAdmin> test(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        Example example = new Example(SysAdmin.class);
        Example.Criteria criteria = example.createCriteria();
        List<SysAdmin> sysAdmins = adminMapper.selectByExample(example);
        if (CollUtil.isNotEmpty(sysAdmins)) {
            sysAdmins.stream().forEach(admin -> admin.setPassword(null));
        }
        return sysAdmins;
    }
}